<% columns = @product.variants_with_master.collect {|v| v.parameter_values.count}.max %>

<% row = cycle("even", "odd") %>
<tr class="<%= row %>" <%= variant.is_master? ? "style='background-color: #7E7E7E;'" : "" %>>
  <td><%= variant.number %></td>
  <td><%= number_to_currency(variant.price) %></td>
  <td><%= t "enumerations.product.state.#{variant.state}" %></td>
  <% unless variant.parameter_values.blank? %>
    <% variant.parameter_values.each do |parameter_value| %>
      <td>
        <strong><%= parameter_value.parameter.name %>:</strong> <%= parameter_value.value %>
      </td>
    <% end %>
    <% (columns - variant.parameter_values.count).times do %>
      <td></td>
    <% end %>
  <% else %>
      <td colspan="<%= columns %>">
        Nemá žádné parametry
      </td>
  <% end %>
  <td <%= variant.is_master? ? "style='background-color: white;'" : "" %>>
    <% permitted_to? :delete, :admin_variants do %>
      <% if variant.is_master? %>
        <%= button_to_delete_disabled "Hlavní variantu produktu nemůžete smazat" %>
      <% else %>
        <%= button_to_delete "Smazat variantu", admin_product_variant_path(params[:product_id], variant.id) if !variant.deleted? %>
      <% end %>
    <% end %>
    <% permitted_to? :edit, :admin_variants do %>
      <%= remote_button_to_edit 'Editovat variantu', edit_admin_product_variant_path(params[:product_id], variant.id), "variant" %>
    <% end %>
  </td>
</tr>